<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "open_info".
 *
 * @property int $id 主键
 * @property int $third_type  微信类型 1 小程序 2 公众号
 * @property string $app_id 小程序/公众号app_id
 * @property string $openid 用户openid
 * @property string $mobile 微信手机号
 * @property string $nick_name 用户昵称
 * @property int $gender 性别 1 男 2 女 3 未知
 * @property string $province 省
 * @property string $city 市
 * @property string $country 国家
 * @property string $avatar_url 头像
 * @property string $union_id 联合id
 * @property int $subscribe 是否关注公众号0未关注1已关注
 * @property int $subscribe_time 关注公众号时间
 * @property int $accept_status 接收状态:0-否,1-是
 * @property int $add_time 添加时间
 * @property int $last_time 修改时间
 */
class OpenInfo extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'open_info';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['third_type', 'gender', 'subscribe', 'subscribe_time', 'accept_status', 'add_time', 'last_time'], 'integer'],
            [['app_id'], 'required'],
            [['app_id', 'openid', 'nick_name', 'province', 'city', 'country'], 'string', 'max' => 100],
            [['mobile'], 'string', 'max' => 11],
            [['avatar_url'], 'string', 'max' => 255],
            [['union_id'], 'string', 'max' => 200],
            [['openid', 'app_id'], 'unique', 'targetAttribute' => ['openid', 'app_id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'third_type' => 'Third Type',
            'app_id' => 'App ID',
            'openid' => 'Openid',
            'mobile' => 'Mobile',
            'nick_name' => 'Nick Name',
            'gender' => 'Gender',
            'province' => 'Province',
            'city' => 'City',
            'country' => 'Country',
            'avatar_url' => 'Avatar Url',
            'union_id' => 'Union ID',
            'subscribe' => 'Subscribe',
            'subscribe_time' => 'Subscribe Time',
            'accept_status' => 'Accept Status',
            'add_time' => 'Add Time',
            'last_time' => 'Last Time',
        ];
    }
}
